let path = require('path');
let HtmlWebpackPlugin = require('html-webpack-plugin');
let webpack = require('webpack');

module.exports = {
    mode: 'development',
    entry: {
        index: './src/index.js'
    },
    output: {
        filename: '[name].js',
        path: path.resolve('dist')
    },
    devServer: {
        contentBase: 'dist',
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './public/index.html',
            filename: 'index.html'
        }),
        // 引用第三方库时会先去react_manifest.json中查询是否有相关的映射，有就会调用react_dll的方法，而不会再次打包第三方库
        new webpack.DllReferencePlugin({
            manifest: path.resolve(__dirname, 'dist', 'react_manifest.json')
        })
    ]
}